//
//  CKOrderTableViewCell.m
//  FreshBee
//
//  Created by chenkai on 16/10/15.
//  Copyright © 2016年 iOS013. All rights reserved.
//

#import "CKOrderTableViewCell.h"
#import <UIImageView+WebCache.h>
#import "CKOrderModel.h"
#import "CKOrderGoods.h"

@interface CKOrderTableViewCell()

@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

@property (weak, nonatomic) IBOutlet UILabel *stateLabel;
@property (weak, nonatomic) IBOutlet UIImageView *imageView1;
@property (weak, nonatomic) IBOutlet UIImageView *imageView2;
@property (weak, nonatomic) IBOutlet UIImageView *imageView3;
@property (weak, nonatomic) IBOutlet UIImageView *imageVeiw4;
@property (weak, nonatomic) IBOutlet UILabel *goodsCountAndMoney;
@property (weak, nonatomic) IBOutlet UIImageView *moreImageVeiw;

@end

@implementation CKOrderTableViewCell

- (void)setOrderModel:(CKOrderModel *)orderModel{
    _orderModel = orderModel;
    
    self.timeLabel.text = orderModel.lastUpdateTime;
    self.goodsCountAndMoney.text = [NSString stringWithFormat:@"共%ld件商品    实付:$%@",orderModel.order_goods.count,orderModel.real_amount];
    
    [self.moreImageVeiw setHidden:orderModel.order_goods.count < 5];
    [self.imageVeiw4 setHidden: orderModel.order_goods.count < 4];
    [self.imageView3 setHidden: orderModel.order_goods.count < 3];

    CKOrderGoods *goods;
    for(int i = 0;i < orderModel.order_goods.count;i++){
        goods = orderModel.order_goods[i];

        if(i == 0){
            [self.imageView1 sd_setImageWithURL:[NSURL URLWithString:goods.img]];
        }
        if(i == 1){
            [self.imageView2 sd_setImageWithURL:[NSURL URLWithString:goods.img]];
        }
        if(i == 2){
            [self.imageView3 sd_setImageWithURL:[NSURL URLWithString:goods.img]];
        }
        if(i == 3){
            [self.imageVeiw4 sd_setImageWithURL:[NSURL URLWithString:goods.img]];
        }
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (IBAction)youKnowBtnClick:(UIButton *)sender {
    NSLog(@"发福利按钮被点击");
}













@end
